package puzzle.projecteuler.p100;

public class Problem030 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int s = 0;
		for (int i = 0; i < 1000000; i ++) {
			if (check(i)) {
				System.out.println(i);
				s += i;
			}
		}
		System.out.println("\n\n" + s);
	}

	private static boolean check(int i) {
		
		int s = 0;
		String n = String.valueOf(i);
		for (char a: n.toCharArray()) {
			s += Math.pow(a-'0', 5);
		}
		return (s == i);
	}
}
